public class WaterHeater {

    private enum State {
        SLEEPING, WAITING, HEATING, REPAIRING
    }

    private State currentState = State.SLEEPING;

    private int temperature;
    private boolean hasWater;
    private boolean isBroken;

    public void updateState() {
        switch (currentState) {
            case SLEEPING:
                if (isMorning()) { // 判断当前时间是否为早上 7 点
                    currentState = State.WAITING;
                }
                break;
            case WAITING:
                if (temperature < 20 && hasWater) {
                    currentState = State.HEATING;
                } else if (isNight()) { // 判断当前时间是否为晚上 11 点
                    currentState = State.SLEEPING;
                }
                break;
            case HEATING:
                if (temperature >= 100) {
                    currentState = State.WAITING;
                } else if (isBroken) {
                    currentState = State.REPAIRING;
                }
                break;
            case REPAIRING:
                if (isRepaired()) { // 判断水箱是否已维修
                    currentState = State.WAITING;
                }
                break;
        }
    }

    // 判断当前时间是否为早上 7 点
    private boolean isMorning() {
        // ... 使用日期和时间类库判断当前时间是否为早上 7 点
        return false;
    }

    // 判断当前时间是否为晚上 11 点
    private boolean isNight() {
        // ... 使用日期和时间类库判断当前时间是否为晚上 11 点
        return false;
    }

    // 判断水箱是否已维修
    private boolean isRepaired() {
        // ... 使用其他方法或传感器判断水箱是否已维修
        return false;
    }

    // 其他方法，例如获取温度、检测水量、模拟故障等
    public int getTemperature() {
        return temperature;
    }

    public void setTemperature(int temperature) {
        this.temperature = temperature;
    }

    public boolean hasWater() {
        return hasWater;
    }

    public void setHasWater(boolean hasWater) {
        this.hasWater = hasWater;
    }

    public boolean isBroken() {
        return isBroken;
    }

    public void setBroken(boolean broken) {
        isBroken = broken;
    }
}
